﻿@model PsCommand

@{
    ViewBag.Title = "Details";
}
@using (Html.BeginForm())
{
    @* @Html.AntiForgeryToken() *@
    @Html.ValidationSummary(true)
<div style="margin-left:100px; margin-bottom:30px; float:left;">
<h2>คำสั่งเลขที่ @Model.CmdRefNo</h2>
<h3 class="header">รายละเอียดคำสั่ง</h3>
    <div class="detail">

    <table class="info">
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.CmdFlag)
            </td>
            <td class="display-field">
                @Model.GetFlagName
            </td>
        </tr>
        <tr>
            <td class="display-label">
                @Html.DisplayNameFor(model => model.CmdDraftNo)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.CmdDraftNo)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.CmdName)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.CmdName)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.CmdDescr)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.CmdDescr)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.CmdRefNo)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.CmdRefNo)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.CmdTypeId)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.HrmPsCommandTypes.CmdTypeName)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.EmpTypeId)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.HrmPsEmployeeTypes.Name)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.JobSiteId)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.HrmMpJobSites.Name)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.CmdStatus)
            </td>
            <td class="display-field">
                @Model.GetCmdStatusName
            </td>
        </tr>
        @*<tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.approved_type)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.approved_type)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.approved_seq)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.approved_seq)
            </td>
        </tr>*@
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.ApprovedName)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.ApprovedName)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.ApprovedPositions)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.ApprovedPositions)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.ApprovedDate)
            </td>
            <td class="display-field">
                @*@Html.DisplayFor(model => model.ApprovedDate)*@
                @Common.GetLongDateString(Model.ApprovedDate)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.CmdRptDate)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.CmdRptDate)
            </td>
        </tr>
        @*<tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.inv_type_seq)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.inv_type_seq)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.confirm)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.confirm)
            </td>
        </tr>*@
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.RptHeader)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.RptHeader)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.Remarks)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.Remarks)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                @Html.LabelFor(model => model.RecordStatus)
            </td>
            <td class="display-field">
                @Common.GetRecordStatusName(Model.RecordStatus)
            </td>
        </tr>
        @*<tr>
            <td class="display-label">
                @Html.DisplayNameFor(model => model.CreatedBy)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.CreatedBy)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.CreatedWhen)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.CreatedWhen)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.UpdatedBy)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.UpdatedBy)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                 @Html.DisplayNameFor(model => model.UpdatedWhen)
            </td>
            <td class="display-field">
                @Html.DisplayFor(model => model.UpdatedWhen)
            </td>
        </tr>*@
    </table>

    <br />

    <table class="tablesorter" style="width:100%">
        <thead>
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.HrmPsCommandDtls.HrmPsEmployees.FullName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.HrmPsCommandDtls.StartDate)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.HrmPsCommandDtls.NewPosId)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.HrmPsCommandDtls.NewClassId)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.HrmPsCommandDtls.NewExecPosId)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.HrmPsCommandDtls.NewJobSiteId)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.HrmPsCommandDtls.NewWorkingJobSiteId)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.HrmPsCommandDtls.Remarks)
                </th>
            </tr>
        </thead>
        <tbody>
        @foreach (var item in Model.col_hrm_ps_command_dtls)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.HrmPsEmployees.FullName)
                </td>
                <td>
                    @(item.StartDate.HasValue ? item.StartDate.Value.ToLongDateString() : "")
                </td>
                <td>
                    @Html.DisplayFor(model => item.NewPosRef) : @Html.DisplayFor(model => item.NewPosName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.new_HrmMpClasses.ClassName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.NewExecPosName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.NewJobSiteName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.NewWorkingJobSiteName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.NewWorkingJobSiteName)
                </td>
            </tr>
        }
        </tbody>

    </table>



<p>
    @if (Model.RecordStatus != "A" && Model.RecordStatus != "P")
    {
        <input type="submit" value="ส่งอนุมัติ" />
        @Html.ActionLink("แก้ไข", "Edit", new { id=Model.CmdId })@Html.Raw("&nbsp;|&nbsp;")
        @*@Html.ActionLink("ส่งอนุมัติ", "Approve", new { id = Model.CmdId })@Html.Raw("|")*@
    }
    @if(Model.RecordStatus == "A" && Model.CmdStatus != "R")
    {
        @Html.ActionLink("ให้คำสั่งมีผลเดี๋ยวนี้", "UpdateCommand", new { id=Model.CmdId })@Html.Raw("&nbsp;|&nbsp;")
    }
    @Html.ActionLink("กลับไปหน้าแสดงรายการทั้งหมด", "Index")
</p>
        </div>
</div>
}

@section scripts
{
    <script>
        jQuery(function ($) {
            $("[type='submit']").click(function () {
                var ans = confirm("ต้องการส่งอนุมัติ ใช่หรือไม่?");

                if (!ans) return false;
            })
        })
    </script>
}